package com.example.javaeefinal.Service.Imp;

import com.example.javaeefinal.Mapper.DepartmentMapper;
import com.example.javaeefinal.Service.DepartmentService;
import com.example.javaeefinal.pojo.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentImpl implements DepartmentService {
    @Autowired
    private DepartmentMapper depMapper;
    @Override
    public void createNewDepartment(String name, int principal) {
        depMapper.createNewDepartment(name,principal);
        initNewDepInfo(selectLastCreateDepartmentId());
    }

    @Override
    public int selectLastCreateDepartmentId() {
        return depMapper.selectLastCreateDepartmentId();
    }

    @Override
    public void initNewDepInfo(int id) {
        depMapper.initNewDepInfo(id);
    }

    @Override
    public void deleteDepartmentById(int id) {
        depMapper.deleteDepartmentById(id);
    }

    @Override
    public Department selectDepartmentById(int id) {
        return depMapper.selectDepartmentById(id);
    }

    @Override
    public void updateDepartmentById(int id, String departmentName, int principal) {
        depMapper.updateDepartmentById(id,departmentName,principal);
    }

    @Override
    public void updateDepInfoById(int id, String mail, String address, String code) {
        depMapper.updateDepInfoById(id,mail,address,code);
    }

    @Override
    public List<Department> getAllDepartment() {
        return depMapper.getAllDepartment();
    }
}


